/*    */ package blockbuster.components.expiration;
/*    */ 
/*    */ import blockbuster.components.BedrockComponentBase;
/*    */ import blockbuster.emitter.BedrockEmitter;
/*    */ import blockbuster.emitter.BedrockParticle;
/*    */ import blockbuster.math.molang.MolangException;
/*    */ import blockbuster.math.molang.MolangParser;
/*    */ import com.google.gson.JsonArray;
/*    */ import com.google.gson.JsonElement;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import javax.vecmath.Vector3d;
/*    */ import net.minecraft.block.Block;
/*    */ import net.minecraft.init.Blocks;
/*    */ import net.minecraft.util.ResourceLocation;
/*    */ import net.minecraft.util.math.BlockPos;
/*    */ import net.minecraftforge.fml.common.registry.ForgeRegistries;
/*    */ import net.minecraftforge.registries.IForgeRegistryEntry;
/*    */ 
/*    */ public abstract class BedrockComponentExpireBlocks
/*    */   extends BedrockComponentBase {
/* 22 */   public List<Block> blocks = new ArrayList<>();
/*    */   
/* 24 */   private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
/*    */ 
/*    */ 
/*    */   
/*    */   public BedrockComponentBase fromJson(JsonElement element, MolangParser parser) throws MolangException {
/* 29 */     if (element.isJsonArray())
/*    */     {
/* 31 */       for (JsonElement value : element.getAsJsonArray()) {
/*    */         
/* 33 */         ResourceLocation location = new ResourceLocation(value.getAsString());
/* 34 */         Block block = (Block)ForgeRegistries.BLOCKS.getValue(location);
/*    */         
/* 36 */         if (block != null)
/*    */         {
/* 38 */           this.blocks.add(block);
/*    */         }
/*    */       } 
/*    */     }
/*    */     
/* 43 */     return super.fromJson(element, parser);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public JsonElement toJson() {
/* 49 */     JsonArray array = new JsonArray();
/*    */     
/* 51 */     for (Block block : this.blocks) {
/*    */       
/* 53 */       ResourceLocation rl = ForgeRegistries.BLOCKS.getKey((IForgeRegistryEntry)block);
/*    */       
/* 55 */       if (rl != null)
/*    */       {
/* 57 */         array.add(rl.toString());
/*    */       }
/*    */     } 
/*    */     
/* 61 */     return (JsonElement)array;
/*    */   }
/*    */ 
/*    */   
/*    */   public Block getBlock(BedrockEmitter emitter, BedrockParticle particle) {
/* 66 */     if (emitter.world == null)
/*    */     {
/* 68 */       return Blocks.field_150350_a;
/*    */     }
/*    */     
/* 71 */     Vector3d position = particle.getGlobalPosition(emitter);
/*    */     
/* 73 */     this.pos.func_189532_c(position.getX(), position.getY(), position.getZ());
/*    */     
/* 75 */     return emitter.world.func_180495_p((BlockPos)this.pos).func_177230_c();
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuster\components\expiration\BedrockComponentExpireBlocks.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */